import request from '@/utils/request'

// 查询数据集列表
export function listDataset(query) {
    return request({
        url: '/dataset/list',
        method: 'get',
        params: query
    })
}


// 新增数据集
export function addDataset(data) {
    return request({
        url: '/dataset/create',
        method: 'post',
        data: data
    })
}

// 删除知识库文件
export function delDocument(datasetID, ids) {
    return request({
        url: '/document/remove/' + datasetID + '/' + ids,
        method: 'delete'
    })
}


// 获取知识库文件列表
export function getDocuments(datasetID, query) {
    return request({
        url: '/document/' + datasetID,
        method: 'get',
        params: query
    })
}


// 上传文件到知识库
export function uploadFiles(files, datasetID) {
    const formData = new FormData()
    files.forEach(file => {
        formData.append('files', file)
    })
    return request({
        url: '/upload/' + datasetID,
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}
